/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alcatelparser.tags;

import alcatelparser.modules.BuilderFactory;
import alcatelparser.modules.I;

/**
 *
 * @author geniuz
 */
public class CDETag extends DefaultParserTag
{

    public CDETag()
    {
    }

    public final void parseTag(int ai[], int i)
    {
        _array = ai;
        _startParsePosition = i;
        setStandartLength(ai, i);
        if(isFullForm())
            BuilderFactory.getBuilder().writeTagContent(5, 0, getTagPropertiesValue(I.I(5511)), getTagIdentifyContent(i, i + 1));
        int j = i + 2;
        int k = _array[j];
        if(toHex(k).equals(I.I(5536)))
            parseTypeOfTraffic(j);
        else
            parseTariffRegimCode(j);
    }

    private void parseTypeOfTraffic(int i)
    {
        int j = _array[i + 2];
        if(isFullForm())
        {
            String p1 = getTagPropertiesValue((new StringBuilder()).append(I.I(5499)).append(j).toString());
            String p2 = getTagPropertiesValue(I.I(3052));
            String s = (new StringBuilder()).append(getTagIdentifyContent(i, i + 1)).append(toHex(j)).append(I.I(5425)).append(p1).toString();
            BuilderFactory.getBuilder().writeTagContent(6, 0,p2, s);
        } else
        if(isTagChecked(I.I(3038)))
        {
            String s1 = isFieldsDecoding() ? getTagPropertiesValue((new StringBuilder()).append(I.I(5499)).append(j).toString()) : toHex(j);
            BuilderFactory.getBuilder().writeTagContent(6, 0, getReducedTagPropertiesValue(I.I(3052)), s1);
        }
    }

    private void parseTariffRegimCode(int i)
    {
        if(isFullForm())
        {
            String s = (new StringBuilder()).append(getTagIdentifyContent(i, i + 1)).append(_array[i + 2]).toString();
            BuilderFactory.getBuilder().writeTagContent(6, 0, getTagPropertiesValue(I.I(3104)), s);
        } else
        if(isTagChecked(I.I(3087)))
        {
            String s1 = toHex(_array[i + 2]);
            BuilderFactory.getBuilder().writeTagContent(1, 0, getReducedTagPropertiesValue(I.I(3104)), s1);
        }
    }
}
